<?php
if (isset($_REQUEST[session_name()])) session_start();
set_magic_quotes_runtime(0);
include ("../include/start.inc.php");
include ("../include/config.inc.php");
include ("../include/setting.inc.php");
include ("../include/function.inc.php");
if (get_magic_quotes_gpc()) {
    $_GET    = my_stripSlashes($_GET);
    $_POST   = my_stripSlashes($_POST);
    $_COOKIE = my_stripSlashes($_COOKIE);
}
$useragent=$_SERVER['HTTP_USER_AGENT'];
$ip=getenv("HTTP_X_FORWARDED_FOR");
if (empty($ip) || $ip=='unknown') { $ip=getenv("REMOTE_ADDR"); }
global  $auth;
if 
($_SESSION['uip']==$ip && $_SESSION['uagent']==$useragent && $_COOKIE['usid']==$_SESSION['usid'] && $_SESSION['admin']=='admin') 
{$admin='1';} else 
{$admin='0'; $auth='0';  
if ($_SESSION['uip']!=$ip && $_SESSION['admin']=='admin') {
	session_destroy();
	setcookie("usid", "", time()+9999999);
	echo '<br />У вас сменился IP-адрес, необходимо заного ввести логин и пароль!<br />
	<fieldset title="Вход">
<form action="/login.php" method="post" name="enter2">
	<dl class="dl">
		<dt class="dt2">Логин:</dt>
		<dd class="dd2"><input type="text" name="login" maxlength="20" size="22" /></dd>
	</dl>
	   <dl>
		<dt class="dt2">Пароль:</dt>
		<dd class="dd2"><input type="password" name="pass" maxlength="20" size="22" /></dd>
	</dl>
    <input name="auto" type="checkbox" value="1" id="autos" checked="checked" /><label for="autos">Входить автоматически</label><br />
		<a class="lostpass" href="pass.php">Забыли пароль?</a>
        <input name="page" type="hidden" value="'.$_SERVER['PHP_SELF'].'" />
<input type="submit" id="enter" name="submit" class="buttons enter"  value="Вход"  />
</form>

<!-- disabled="disabled"-->
</fieldset>	
	';	};
	echo '<br />Доступ запрещен! <br /> <a href="../index.php" rel="home">ГЛАВНАЯ</a>';};
ob_get_contents();
ob_end_flush();
ob_start ("ob_gzhandler");

$profres = sql_query("SELECT * FROM user WHERE id='$id'"); //извлекаем из базы все данные о пользователе
$prof = mysql_fetch_array($profres);
$tz=$prof['timezone'];
date_default_timezone_set('Europe/Moscow');
$posmin=strpos ( $tz , ":");
for ($i=0;$i<$posmin;$i++)
{ $hourtz.=$tz[$i];}
for ($i=$posmin+1;$i<$posmin+3;$i++)
{ $mintz.=$tz[$i];}
$minut=date("i")+$mintz;
$chas=date("H")+$hourtz;
$day=date("d");
$month=date("m");
$year=date("Y");
$second=date("s");
if ($month==1) {$prevmonth=cal_days_in_month(CAL_GREGORIAN, 12, $year);} else
{$prevmonth=cal_days_in_month(CAL_GREGORIAN, $month-1, $year);}
$nowmonth=cal_days_in_month(CAL_GREGORIAN, $month, $year);
if ($minut>59) {$minut=$minut-60;$chas++;} 
if ($minut<10) {$minut='0'.$minut;} 
if ($chas>23) {$chas=$chas-24;$day++;}
if ($chas<0) {$chas=24+$chas;$day--;}
if ($day<1) {$day=$prevmonth;$month--;}
if ($day>$nowmonth) {$day=1;$month++;}
if ($month<1) {$month=12;$year--;}
if ($month>12) {$month=1;$year++;}
if (dirname($_SERVER['PHP_SELF'])!='\\') ($dir='../');
$ned=strftime("%W");
$perv_sem=$ned-35+1;
$vtor_sem=$ned+17+1;
if ($ned<35) {
if ($vtor_sem%2==0) {$chet=1;} else {$chet=0;}
$week=$vtor_sem;
} else {
$week=$perv_sem;
if ($perv_sem%2==0) {$chet=1;} else {$chet=0;}}

require ("../include/get.inc.php");
require ("../include/title.inc.php");
//require ("../include/cryptpass.inc.php");
date_default_timezone_set('Europe/Moscow');
include ("../include/info.inc.php");
$login=$_SESSION['ulogin'];
$id=$_SESSION['uid'];
require_once '../lib/bbcode/bbcode.lib.php';
if ($admin==1) {
include ("header-design.php");
}
    ?>